package com.example.demo.mall.mapper;



import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.mall.entity.Order;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface OrderMapper extends BaseMapper<Order> {
    // 根据订单号查询
    Order selectByOrderNo(@Param("orderNo") String orderNo);

    // 更新订单状态（带乐观锁版本号控制示例）
    @Update("UPDATE `order` SET status = #{status}, version = version + 1 WHERE id = #{id} AND version = #{version}")
    int updateOrderStatus(@Param("id") Long id,
                          @Param("status") Integer status,
                          @Param("version") Integer version);
}
